package screen

import (
	"github.com/gdamore/tcell"
)

var (
	StyleSheetChoiceNo  = tcell.StyleDefault.Foreground(tcell.ColorBlack).Background(tcell.ColorWhite)
	StyleSheetChoiceYes = tcell.StyleDefault.Foreground(tcell.ColorOrange).Background(tcell.ColorWhite)
)

func (s *Screen) ShowSheetChoice() {
	s.ScreenPaintFuncClear(PageSheetChoice)
	for i, SheetName := range s.SheetList {
		if i == s.SheetCur {
			s.ScreenPaintFuncAdd(PageSheetChoice, PaintFunc{Func: s.DrawSheetChoice, Params: ParamsDrawSheetChoice{
				PointStartX: 1,
				PointStartY: i,
				PointEndX:   42,
				PointEndY:   3,
				SheetName:   SheetName,
				LineStyle:   StyleSheetChoiceYes,
			}})
		} else {
			s.ScreenPaintFuncAdd(PageSheetChoice, PaintFunc{Func: s.DrawSheetChoice, Params: ParamsDrawSheetChoice{
				PointStartX: 1,
				PointStartY: i,
				PointEndX:   42,
				PointEndY:   3,
				SheetName:   SheetName,
				LineStyle:   StyleSheetChoiceNo,
			}})
		}
	}

}

type ParamsDrawSheetChoice struct {
	PointStartX int
	PointStartY int
	PointEndX   int
	PointEndY   int
	SheetName   string
	LineStyle   tcell.Style
}

func (s *Screen) DrawSheetChoice(ParamsIf interface{}) {
	Params := ParamsIf.(ParamsDrawSheetChoice)
	s.EmitStr(Params.PointStartX+1, Params.PointStartY+1, Params.LineStyle, Params.SheetName)
}
